<template>
<div class="list">
        <div class="article_item" v-for="item in currentList" :key="item.art_id">
          <h3 class="van-ellipsis">{{ item.title }}</h3>
          <div class="img_box" v-if="item.cover.type === 1">
            <img :src="item.cover.images[0]"
            class="w100" />
          </div>
          <div class="img_box" v-else-if="item.cover.type === 3">
            <img :src="item.cover.images[0]"
            class="w33" />
             <img :src="item.cover.images[1]"
            class="w33" />
             <img :src="item.cover.images[2]"
            class="w33" />
          </div>
          <div class="info_box">
            <span>{{ item.aut_name }}</span>
            <span>{{ item.comm_count }}评论</span>
            <span>{{ item.pubdate }}</span>
          </div>
        </div>
      </div>
  <!-- <div class="list">
    <div class="article_item">
      <h3 class="van-ellipsis">乾坤未定：你我皆是黑马</h3>
      <div class="img_box">
        <img src="https://shuiruohanyu.gitee.io/yyds/images/index.png" class="w100" />
      </div>
      <div class="info_box">
        <span>小团团</span>
        <span>0评论</span>
        <span>2018-11-29T17:02:09</span>
      </div>
    </div>
    <div class="article_item">
      <h3 class="van-ellipsis">乾坤未定：你我皆是黑马</h3>
      <div class="img_box">
        <img src="https://shuiruohanyu.gitee.io/yyds/images/index.png" class="w33" />
        <img src="https://shuiruohanyu.gitee.io/yyds/images/index.png" class="w33" />
        <img src="https://shuiruohanyu.gitee.io/yyds/images/index.png" class="w33" />
      </div>
      <div class="info_box">
        <span>小团团</span>
        <span>0评论</span>
        <span>2018-11-29T17:02:09</span>
      </div>
    </div>
    <div class="article_item">
      <h3 class="van-ellipsis">乾坤未定：你我皆是黑马</h3>
      <div class="info_box">
        <span>小团团</span>
        <span>0评论</span>
        <span>2018-11-29T17:02:09</span>
      </div>
    </div>
  </div> -->
</template>
<script>
// 引入当前激活的分类id
import { mapGetters } from 'vuex'
export default {
  computed: {
    ...mapGetters(['currentChannel', 'currentList'])
  },
  //侦听 currentChannel的变化，newValue是最新值
  //因为currentChannel的初始值为"",所以刚打开页面就默认以第一个频道发送了一次请求，所以刚打开页面也会触发watch
  watch: {
    currentChannel (newValue,oldValue) {
      // newValue是当前最新的激活的id,也就是说将当前点击的频道的id传给getNewList
      this.$store.dispatch('newlist/getNewList', newValue)
    }
  }
}
</script>
